function logon() {
    //用户名'
    var submitFlg = true;
    var user = {register: /^[\w]{1,12}$/, tip: '请输入1-6位的英文、数字、下划线'};
    var username = document.getElementById("userName").value;
    var spans = document.getElementById("userName").parentNode.getElementsByTagName("span");
    spans[0].innerHTML = "";
    if (!user.register.test(username)) {
        spans[0].innerHTML = user.tip;
        submitFlg = false;
    }
//    密码
    var pass = {register: /^[\w]{6,12}$/, tip: '请输入6-12位的英文、数字、下划线'};
    var passWord = document.getElementById("passWord").value;
    var remark = document.getElementById("passWord").parentNode.getElementsByTagName("span");
    remark[0].innerHTML = "";
    if (!user.register.test(passWord)) {
        remark[0].innerHTML = pass.tip;
        submitFlg = false;
    }
    return submitFlg;

}
// //登录AJAX请求
$(".entry").click(function () {
    $.ajax({
        url:"http://localhost:8080/loginManager",
        type:"GET",
        dataType:"JSON",
        // async:true,
        data:{

            account:$("#userName").val(),
            password:$("#passWord").val(),
        },
        success:function(data){
            if(data.code==100){
                window.location.href='/business_personal';
            }
        },
        // error:function(){
        //     alert("异常")
        // }
    });
});

// 店铺商品编辑
$(".bus-goods").click(function () {
    var goodsid=$(this).data('id');

    $(".my-sub2").click(function () {
        var goodsName=$("#goodsName").val();
        var goodsPrice=$("#goodsPrice").val();

        $.ajax({
            url:'/administrator/upGoodsDate',
            type:"GET",
            dataType:"JSON",
            data: {
                id:goodsid,
                goodsName:goodsName,
                goodsPrice:goodsPrice
            },
            success:function (data) {
                if(data.code==100){
                    alert("修改成功！");
                    location.reload();
                    $("#myModal2").hide();
                }else {
                    alert("修改失败！")
                }
            }
            }

        )
    })
})

// 店铺商品推荐
$(".shop-recommend").click(function () {
    var shopid=$(this).data('shopid');
    var goodid=$(this).data('goodid');
    var goodsname=$(this).data('goodsname');
    var goodsphoto=$(this).data('goodsphoto');
console
    $.ajax({
        url:'/business/addShowGood',
        type:"GET",
        dataType:"JSON",
        data:{
            storeId:shopid,
            id:goodid,
            goodsName:goodsname,
            photoUrl:goodsphoto
        },
        success:function (data) {
              if(data.code==100){
                  alert("推荐成功！");
                  location.reload();
              }else{
                  alert("推荐失败！");
              }
        },
    })
})

// 店铺商品删除
var shop_delete=$(".shop-delete");
for(var i=0;i<shop_delete.length;i++){
    $(shop_delete[i]).click(function () {
        var tr=$(this).parent().parent().parent();
        tr.remove();
        var id=$(this).data('id');
        console.log(id)
        $.ajax({
            url:'/business/delectGoods',
            type:"GET",
            dataType:"JSON",
            data:{
                id:id
            },
        });

    })
}
